import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:lianwenke20220712/bean/news_info.dart';
import 'package:lianwenke20220712/http/httpUtils.dart';
/// FileName 连文科
///
/// @Author/// @Date 2022/7/12 15:32
///
/// @Description 新闻详情页面
class NewsInfoWidget extends StatefulWidget {
  final int id;
  const NewsInfoWidget({Key key,this.id}) : super(key: key);

  @override
  _NewsInfoWidgetState createState() => _NewsInfoWidgetState();
}

class _NewsInfoWidgetState extends State<NewsInfoWidget> {
  Result _result;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    xinwen();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body:_result == null ?Center(child: CircularProgressIndicator(),) : ListView(
          children: [
            Text(_result.title,style: TextStyle(fontSize: 20,color: Colors.redAccent),),
            Html(data: _result.content),
          ],
        ),
    );
  }

  void xinwen() {
    HttpUtils().MendGet('http://mobile.bwstudent.com/hotNews/news/v1/findNewsDetail',isCache: true,map: {'newsId':widget.id},onSuccess: (data){
      setState(() {
          _result = NewsInfo.fromJson(data).result;
      });
    });
  }
}
